package com.example.springbootdemo.config;

import com.example.springbootdemo.filter.ImgFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class WebConfig {

    @Bean
    public FilterRegistrationBean timeFilter(){
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        ImgFilter imgFilter = new ImgFilter();
        filterRegistrationBean.setFilter(imgFilter);

        //自定义需要的过滤url
        List<String> list = new ArrayList();
        list.add("/html/*");
//        list.add("/img/*");
        filterRegistrationBean.setUrlPatterns(list);
        return filterRegistrationBean;
    }
}
